<?php


/**
* CakePHP Routines Plugin
* http://cake-routines-plugin.googlecode.com
*
* @package cake.plugins.routines
* @subpackage cake.plugins.routines.controllers.components
* @author Ivan Chistyakov <zetruger@gmail.com>
* @version $Id: page_meta.php 40 2010-05-05 14:03:59Z zetruger@gmail.com $
* @link $HeadURL: http://cake-routines-plugin.googlecode.com/svn/trunk/controllers/components/page_meta.php $
* @license MIT License (http://opensource.org/licenses/mit-license.php)
*/


class PageMetaComponent extends Object {

var $components = array('Routines.PageTitle');

var $Controller = NULL;

var $_defaults = array(
	'pageDescription' => NULL,
	'pageKeywords' => NULL,
	'autoSetVars' => TRUE
);

var $settings = array();

function initialize(&$Controller, $settings = array()) {
	$this->Controller = &$Controller;
	$this->settings = $settings;
}

function _mergeSettings($settings = array()) {
	return array_intersect_key(Set::merge($this->_defaults, Configure::read('Components.PageTitle'), $this->settings, get_object_vars($this), $settings), $this->_defaults);
}

function setVarsForLayout($settings = array()) {
	$ctrl = &$this->Controller;
	extract($this->_mergeSettings($settings));
	$ctrl->set('description_for_layout', h($pageDescription));
	$ctrl->set('keywords_for_layout', h($pageKeywords));
}

function beforeRender(&$Controller) {
	extract($this->_mergeSettings());
	if ($autoSetVars) {
		$this->setVarsForLayout();
	}
}

}


?>